package com.xfp.mapper;

import com.xfp.anntation.AutoFill;
import com.xfp.enumclass.OperationClass;
import com.xfp.pojo.dto.ChannelConfigDto;
import com.xfp.pojo.entity.Channel;
import com.xfp.pojo.entity.Goods;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ChannelMapper {
    /**
     * 货道查询商品
     * @param innerCode
     * @return
     */
    @Select("select * from tb_channel where inner_code = #{innerCode}")
    List<Channel> channelList(String innerCode);

    /**
     * 根据商品id查询商品
     * @param skuId
     * @return
     */
    @Select("select * from tb_sku where sku_id = #{skuId}")
    Goods findGoodsById(String skuId);

    /**
     * 货道配置
     * @param dto
     */
    @AutoFill(OperationClass.INSERT)
    void config(ChannelConfigDto dto);

    /**
     * 删除原数据
     * @param innerCode
     */
    @Delete("delete  from tb_channel where inner_code =#{innerCode}")
    void deleteChannel(String innerCode);

    /**
     * 新增货道配置
     * @param dto
     */
    @AutoFill(OperationClass.INSERT)
    void insertChannel(ChannelConfigDto dto);
}
